package com.deke.course.controller;

import com.deke.course.service.EduCourseService;
import com.deke.entity.EduCourse;
import com.deke.vo.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @version 1.0
 * @Author :LiM
 * @Date :2022/12/28 14:10
 */
@RestController
    @RequestMapping("/core/shoucangCourse")
public class ShoucangCourseController {
    @Autowired
    private EduCourseService courseService;
    /**
     * 根据会员id查询当前用户的所有收藏课程
     * @param memberId
     * @return
     */
    @PostMapping("findFavoriteCourseById/{memberId}")
    public Result queryCourseShoucang(@PathVariable("memberId") String memberId){
        return courseService.queryCourseShoucangByMemId(memberId);
    }
    /**
     * 添加课程收藏
     * @param eduCourse
     * @return
     */
    @PostMapping("/addFavoritescourse")
    public Result addCollectCourse(@RequestBody EduCourse eduCourse){
        return courseService.addCollectCourse(eduCourse);
    }
    /**
     * 取消课程收藏
     * @param eduCourse
     * @return
     */
    @PostMapping("/deleteFavoriteCourse")
    public Result deleteFavoriteCourse(@RequestBody EduCourse eduCourse){
        return courseService.deleteFavoriteCourse(eduCourse);
    }
    /**
     * 根据用户id和课程id查询是否收藏该课程
     * @param course
     * @return
     */
    @PostMapping("/findFavoriteCourse")
    public Result queryCountByMemOrCou(@RequestBody EduCourse course){
        return courseService.findFavoriteCourse(course);
    }
}
